﻿<?xml version="1.0" encoding="utf-8" ?>

<sqlMap namespace="ExchangeItem" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  
  <resultMaps>
    <resultMap id="SelectResult" class="ExchangeItem">
      <result property="Id"         column="ID" />
      <result property="Source"  column="Source" />
      <result property="Object"   column="Object" />
      <result property="Target"   column="Target" />
      <result property="Priority"   column="Priority" />
      <result property="ProcessXML"   column="ProcessXML" />
      <result property="Worked"   column="Worked" />
    </resultMap>
  </resultMaps>

  <statements>

    <select id="SelectItemToWork" resultMap="SelectResult">
      select * from ExchangeItems where worked=false order by priority;
    </select>

    <insert id="Insert" parameterClass="ExchangeItem" resultClass="int">
      insert into ExchangeItems
      (source,object,target,priority,processxml,worked)
      values
      (#Source#, #Object#, #Target#,
      #Priority#, #ProcessXML#,#Worked#)
    </insert>

    <update id="MarkAsWorked" parameterClass="int" resultClass="int">
      update ExchangeItems set worked=true where ID = #value#
    </update>
    
    <delete id="Delete" parameterClass="int" resultClass="int">
      delete from ExchangeItems
      where ID = #value#
    </delete>

  </statements>

</sqlMap>
